package com.sensePlusVR.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sensePlusVR.adapter.NetworkVideoAdapter;
import com.sensePlusVR.base.BaseFragment;
import com.sensePlusVR.bean.LocalVideoItem;
import com.sensePlusVR.main.R;
import com.sensePlusVR.utils.MyLog;
import com.sensePlusVR.widget.sliddel.ItemRemoveRecyclerView;
import com.sensePlusVR.widget.sliddel.OnItemClickListener;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author: Loren
 * @create: 2016-8-10下午3:04:17
 * @desc: 网络 samba upnp 视频界面
 *
 */
@ContentView(R.layout.fragment_video_network)
public class NetworkVideoFragment extends BaseFragment implements OnItemClickListener{
	private static final String TAG = NetworkVideoFragment.class.getSimpleName();
	private List<LocalVideoItem> videoList;
	private NetworkVideoAdapter adapter;
	@ViewInject(R.id.network_video_listview)
	private ItemRemoveRecyclerView network_video_listview;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = x.view().inject(this, inflater, container);
		beforeView();
		initView();
		Log.d(TAG, "onCreateView...");
		return view;
	}
	
	private void getData() {
		videoList = new ArrayList<LocalVideoItem>();
		for (int i = 0; i < 20; i++) {
			LocalVideoItem item = new LocalVideoItem();
			item.setTitle("game" + i);
			item.setLength("1:42");
			item.setSize("450M");
			videoList.add(item);
		}
	}

	private void beforeView() {
		getData();
		adapter = new NetworkVideoAdapter(getActivity(),videoList);
		//adapter.setOnRecyclerViewItemClickListener(this);
	}
	
	private void initView() {
		LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
		network_video_listview.setLayoutManager(layoutManager);
		network_video_listview.setAdapter(adapter);
		network_video_listview.setOnItemClickListener(this);
	}

/*	@Override
	public void OnItemClick(View view, LocalVideoItem item) {
		MyPageJump.pageJumpAddObject(getActivity(), VideoPlayActivity.class, Constant.INTENT_VIDEO_PLAY, item);
	}*/
	
    
	@Override
	public void onPause() {
		super.onPause();
		Log.d(TAG, "onPause...");
		
	}
	
	@Override
	public void onStop() {
		super.onStop();
		Log.d(TAG, "onStop...");
	}
	
	@Override
	public void onDestroyView() {
		super.onDestroyView();
		Log.d(TAG, "onDestroyView...");
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		Log.d(TAG, "onDestroy...");
	}

	@Override
	public void onItemClick(View view, int position) {
		//MyToast.showMessage(getActivity(), "item title : " + videoList.get(position).getTitle());
		MyLog.d(TAG, "item title : " + videoList.get(position).getTitle());
	}

	@Override
	public void onDeleteClick(int position) {
		adapter.removeItem(position);
	}

	@Override
	public void onTopClick(int position) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onDeleteState(int x,int y) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void recoveryDrawer() {
		// TODO Auto-generated method stub
		
	}
}
